package com.ddwl.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author wenbin
 * @Description 用户数据统计
 */
public interface DingTalkEnum {

    @AllArgsConstructor
    @Getter
    enum department {
        MASTER( 0,"董事长"),
        CEO( 1,"CEO"),
        ONLINE( 2,"线上部"),
        OFFLINE( 3,"线下部"),
        MARKETING( 4,"市场营销部"),
        TECHNOLOGY( 5,"技术部"),
        FINANCE( 6,"财务部"),
        ADMINISTRATION( 7,"行政部"),
        OPERATIONS( 8,"运营部"),
        DESIGN( 9,"设计部"),
        SALES( 10,"销售部"),
        MARKET( 11,"市场部"),
        CUSTOMER_SERVICE( 12,"客服部"),
        ACADEMY( 13,"商学院"),
        COPY_WRITING( 14,"文案设计部"),
        OPERATIONS2( 15,"运营2部"),
        WAREHOUSE( 16,"仓储服务部"),
        ;
        private Integer code;
        private String name;

        // 根据code获取名称
        public static String getNameByCode(Integer code) {
            for (department t : department.values()) {
                if (t.getCode().equals(code))
                    return t.getName();
            }
            return null;
        }

        // 根据name获取code
        public static Integer getCodeByName(String name) {
            for (department t : department.values()) {
                if (t.getCode().equals(name))
                    return t.getCode();
            }
            return null;
        }


        /**
         * 根据code判断 是否是枚举中的一员
         * @param code
         * @return
         */
        public static boolean isIncludeCode(Integer code) {
            department t = getCode(code);
            if(null==t) return false;
            return true;
        }

        public static department getCode(Integer code) {
            for (department t : department.values()) {
                if (t.getCode().equals(code))
                    return t;
            }
            return null;
        }
        /**
         * 根据name判断 是否是枚举中的一员
         * @param name
         * @return
         */
        public static boolean isIncludeName(String name) {
            department t = getName(name);
            if(null==t) return false;
            return true;
        }

        public static department getName(String name) {
            for (department t : department.values()) {
                if (t.getName().equals(name))
                    return t;
            }
            return null;
        }
    }




}
